<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Search_Model extends CI_Model
{

	function get_featured_product(){

		//$this->db->where('product_id', $product_id);
		$this->db->limit(12);
		$this->db->where('status',1);
		$this->db->order_by('product_id DESC');

		$query = $this->db->get('product');
		if ($query->num_rows() > 0 ) return $query->result();
		return array();		

	}
	
	function select($product_seo_name){
        $query = $this->db->get_where('product', array('product_seo_name'=>$product_seo_name));
		if($query ->num_rows() >0 ) {
			foreach($query ->result() as $row){
				$data[] = $row;
			}
			return $data;
		}
    }

	function get_list_product($user_id=''){

		$this->db->where('user_id', $user_id);

		$query = $this->db->get('product');

		//echo $this->db->last_query();

		if ($query->num_rows() > 0) return $query->result();
		return array();
	}
	
	function get_search($match = '', $page='', $limit=''){
		
		//$match = $this->input->post('search');
		$this->db->like('product_name',$match);
		
		if(!empty($limit))
		$this->db->limit($limit,$page);

		$query = $this->db->get('product');
		//echo $this->db->last_query();
		if ($query->num_rows() > 0) return $query->result();
		return array();
		
	}
	
	function get_search_high($match = '', $page='', $limit=''){
		
		//$match = $this->input->post('search');
		$this->db->like('product_name',$match);
		$this->db->order_by('price desc');
		
		if(!empty($limit))
		$this->db->limit($limit,$page);

		$query = $this->db->get('product');
		//echo $this->db->last_query();
		if ($query->num_rows() > 0) return $query->result();
		return array();
		
	}
	
	function get_search_low($match = '', $page='', $limit=''){
		
		//$match = $this->input->post('search');
		$this->db->like('product_name',$match);
		$this->db->order_by('price asc');
		
		if(!empty($limit))
		$this->db->limit($limit,$page);

		$query = $this->db->get('product');
		//echo $this->db->last_query();
		if ($query->num_rows() > 0) return $query->result();
		return array();
		
	}
	
	function get_store(){
		$query = $this->db->get('store');
		if ($query->num_rows() > 0) return $query->result();
		return array();	
	}
	
}